import router from './index'
import store from '@/store'
// 路由守卫
const whiteList = ['/login']
router.beforeEach((to, from, next) => {
  if (store.getters.token) {
    if (to.path === '/login') {
      if (store.getters.role === '3') {
        next('/admin')
<<<<<<< HEAD
      } else if (store.getters.role === '2') {
        next('/captain')
      } else {
        next('/student')
=======
      } else {
        next('/captain')
>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
      }
    } else {
      next()
    }
  } else {
    if (whiteList.includes(to.path)) {
      next()
    } else {
      next('/login')
    }
  }
})
